package com.easy.easylibdemo.ui.main;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.easy.easylibdemo.R;
import com.easy.easylibdemo.ui.main.adapter.MainListAdapter;
import com.easy.easylibdemo.ui.main.model.DemoBeanImpl;
import com.easy.easylibdemo.ui.main.model.DemoBeanModel;
import com.easylib.base.BaseActivity;
import com.easylib.views.DividerItemDecoration;
import com.guyj.listener.EasyOnItemChildClickListener;

import butterknife.Bind;
import butterknife.ButterKnife;


/**
 * 作　　者: guyj
 * 修改日期: 2016/11/16
 * 描　　述:
 * 备　　注:
 */
public class MainActivity extends BaseActivity {

    @Bind(R.id.recycler)
    RecyclerView recycler;

    private LinearLayoutManager linearLayoutManager;
    private DemoBeanModel demoBeanModel;
    private MainListAdapter mainListAdapter;
    private Intent mIntent;

    @Override
    public int getContentViewId() {
        return R.layout.activity_main;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {

    }

    @Override
    protected void initVariable() {
        demoBeanModel=new DemoBeanImpl();
        linearLayoutManager=new LinearLayoutManager(mContext,LinearLayoutManager.VERTICAL,false);
        mIntent=new Intent();
    }

    @Override
    protected void processLogic(Bundle savedInstanceState) {
        recycler.setLayoutManager(linearLayoutManager);
        recycler.setAdapter(mainListAdapter=new MainListAdapter(this,R.layout.item_main,demoBeanModel.getDemoBean()));
        recycler.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
        mainListAdapter.setEasyOnItemChildClickListener(new EasyOnItemChildClickListener() {
            @Override
            public void onClick(View view, int i) {
                mIntent.setClass(mContext,demoBeanModel.getDemoBean().get(i).getaClass());
                startActivity(mIntent);
            }
        });
    }
}
